#include "mainwindow.h"


void VoltageArmThread::run()
{
    // 防止重复定义
    if(!ros2_stm32_talker_arm_node_cpp)
    {
        ros2_stm32_talker_arm_node_cpp = rclcpp::Node::make_shared("ros2_stm32_talker_arm");
    }
    if(!arm_voltage_pub)
    {
        arm_voltage_pub = ros2_stm32_talker_arm_node_cpp->create_publisher<std_msgs::msg::Int32>("voltage_talker_arm", 10);
    }
    auto voltage_data = std_msgs::msg::Int32();
    if (currentArmVoltageValue <= 0 && currentArmVoltageValue >= -24)
    {
        voltage_data.data = -currentArmVoltageValue;
        arm_voltage_pub->publish(voltage_data);
    }
    else if (currentArmVoltageValue > 0 && currentArmVoltageValue <= 24)
    {
        voltage_data.data = currentArmVoltageValue + 24;
        arm_voltage_pub->publish(voltage_data);
    }
}
